<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>团贷网</title>
    <meta name="description" content="团贷网"/>
    <meta name="keywords" content="团贷网"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
</head>
<body data-type="user">
<div th:include="tpl/tpl-head-reference :: tpl-head-reference"></div>
<div th:include="system/tpl/tpl-head-reference :: tpl-head-reference"></div>
<div class="am-g tpl-g">
    <!-- 头部 -->
    <div th:include="system/tpl/tpl-head :: tpl-head"></div>
    <!-- 风格切换 -->
    <div th:include="tpl/tpl-skiner :: tpl-skiner" class="tpl-skiner"></div>
    <!-- 侧边导航栏 -->
    <div th:include="system/tpl/tpl-leftsider :: tpl-leftside" class="left-sidebar"></div>


    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">用户管理</div>
                        </div>
                        <div class="widget-body  widget-body-lg am-fr">
                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a th:href="@{/admin/user/form}"
                                               class="am-btn am-btn-default am-btn-success"><span
                                                    class="am-icon-plus"></span> 新增
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-u-lg-offset-3">
                                <form class="am-input-group am-input-group-sm tpl-form-border-form cl-p" id="data-form"
                                      onkeydown="if(event.keyCode==13)return false;"
                                      th:action="@{/admin/user/list}">
                                    <input type="text" name="contain_username" class="am-form-field "/>
                                    <input type="hidden" name="page" value="1"/>
                                    <span class="am-input-group-btn">
                                    <button v-on:click="searchForm"
                                            class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"
                                            type="button"></button>
                                    </span>
                                </form>
                            </div>

                            <table width="100%" style="visibility: hidden"
                                   class="am-table am-table-compact am-table-striped tpl-table-black "
                                   id="example-r">
                                <thead>
                                <tr>
                                    <th>数据库</th>
                                    <th>登录名</th>
                                    <th>用户角色</th>
                                    <th>创建时间</th>
                                    <th>激活状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="data-tbody">
                                <template v-for="item in json.content">
                                    <tr>
                                        <td>
                                            <i class="am-icon-plus-square-o am-icon-sm"
                                               data-am-collapse="{target: '#database-tr-{{ item.user.id }}'}"></i>
                                        </td>
                                        <td>{{ item.user.username }}</td>
                                        <td>
                                            <template v-for="role in item.sysRoleList">
                                                <span class="am-badge am-badge-primary am-round">{{ role.roleName }}</span>
                                            </template>
                                        </td>
                                        <td>{{ item.user.createTime | time }}</td>
                                        <td>
                                            <div class="tpl-switch">
                                                <input type="checkbox" class="ios-switch bigswitch tpl-switch-btn"
                                                       data-href="/admin/user/deny?id={{ item.user.id }}"
                                                       v-on:click="defaultBtnLinkVue($event )"
                                                       checked="checked" v-if="item.user.activate">
                                                <input type="checkbox" class="ios-switch bigswitch tpl-switch-btn"
                                                       data-href="/admin/user/open?id={{ item.user.id }}"
                                                       v-on:click="defaultBtnLinkVue($event )"

                                                       v-else="item.activate">

                                                <div class="tpl-switch-btn-view">
                                                    <div>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="tpl-table-black-operation">
                                                <a data-href="/admin/database/listDatabaseWithoutOwnedUI/{{ item.user.id }}"
                                                   v-on:click="defaultOpenLinkVue($event )">
                                                    <i class="am-icon-plus"></i> 授权数据库
                                                </a>
                                                <a href="/admin/user/form?id={{ item.user.id }}">
                                                    <i class="am-icon-pencil"></i> 编辑
                                                </a>
                                                <a data-href="/admin/user/delete?id={{ item.user.id }}"
                                                   data-confirm="删除用户将无法恢复，确定要操作么？"
                                                   v-on:click="defaultBtnLinkVue($event )"
                                                   class="tpl-table-black-operation-del">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr id="database-tr-{{ item.user.id }}" class=" am-collapse">
                                        <td colspan="99">
                                            <div class="row">

                                                <div class="am-u-lg-offset-1 am-u-md-offset-1 am-u-sm-11 am-u-md-8 am-u-lg-8">

                                                    <table width="100%"
                                                           id="database-example-r">
                                                        <thead>
                                                        <tr>
                                                            <th>功能</th>
                                                            <th>分组和职责</th>
                                                            <th>数据库</th>
                                                            <th>用户名</th>
                                                            <th>操作</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody id="database-data-tbody">
                                                        <template v-for="databaseVo in item.databaseFunctionVos">
                                                            <tr>
                                                                <td>
                                                                    <i class="am-icon-plus-square-o am-icon-sm"
                                                                       data-am-collapse="{target: '#function-tr-{{ databaseVo.database.id }}-{{ item.user.id }}'}"></i>
                                                                </td>
                                                                <td>
                                                                    {{ databaseVo.database.groupName }}
                                                                    <span class="am-badge am-badge-secondary am-round">{{ databaseVo.database.groupResponsibilityType | dict "DatabaseGroupResonsibilityTypeEnums" }}</span>
                                                                </td>
                                                                <td>[{{ databaseVo.database.serverName }}]{{
                                                                    databaseVo.database.serverHost }}:{{
                                                                    databaseVo.database.serverPort }}/{{
                                                                    databaseVo.database.databaseName }}
                                                                </td>
                                                                <td>{{ databaseVo.database.username }}</td>
                                                                <td>
                                                                    <div class="tpl-table-black-operation">
                                                                        <a data-href="/admin/function/listFunctionWithoutOwnedUI/{{ databaseVo.userDatabase.id }}"
                                                                           v-on:click="defaultOpenLinkVue($event )">
                                                                            <i class="am-icon-plus"></i> 添加权限
                                                                        </a>
                                                                        <a data-href="/admin/database/verify/{{ databaseVo.database.id }}"
                                                                           v-on:click="defaultBtnLinkVue($event )">
                                                                            <i class="am-icon-link"></i> 检测连通性
                                                                        </a>
                                                                        <a data-href="/admin/userDatabase/deleteByUserIdAndDatabaseId?databaseId={{ databaseVo.database.id }}&userId={{ item.user.id }}"
                                                                           v-on:click="defaultBtnLinkVue($event )"
                                                                           class="tpl-table-black-operation-del">
                                                                            <i class="am-icon-trash"></i> 解除授权
                                                                        </a>
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                            <tr id="function-tr-{{ databaseVo.database.id }}-{{ item.user.id }}"
                                                                class=" am-collapse">
                                                                <td colspan="99">

                                                                    <div class="row">

                                                                        <div class="am-u-lg-offset-1 am-u-md-offset-1 am-u-sm-12 am-u-md-8 am-u-lg-8">

                                                                            <table width="100%"
                                                                                   id="function-example-r">
                                                                                <thead>
                                                                                <tr>
                                                                                    <th>功能名</th>
                                                                                    <th>功能地址</th>
                                                                                    <th>功能类型</th>
                                                                                    <th>操作</th>
                                                                                </tr>
                                                                                </thead>
                                                                                <tbody id="function-data-tbody">
                                                                                    <template v-for="function in databaseVo.functions">
                                                                                        <tr>
                                                                                            <td>{{ function.functionName }}</td>
                                                                                            <td>{{ function.functionUrl }}</td>
                                                                                            <td>{{ function.functionType | dict "FunctionTypeEnums" }}</td>
                                                                                            <td>
                                                                                                <div class="tpl-table-black-operation">
                                                                                                    <a data-href="/admin/functionUserDatabase/deleteByFunctionIdAndUserDatabaseId?functionId={{ function.id }}&userDatabaseId={{ databaseVo.userDatabase.id }}"
                                                                                                       v-on:click="defaultBtnLinkVue($event )"
                                                                                                       class="tpl-table-black-operation-del">
                                                                                                        <i class="am-icon-trash"></i> 解除授权
                                                                                                    </a>
                                                                                                </div>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </template>
                                                                                </tbody>
                                                                            </table>
                                                                        </div>
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </template>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>

                                        </td>
                                    </tr>
                                </template>
                                </tbody>
                            </table>
                            <div class="am-u-lg-12 am-cf">
                                <div th:include="system/tpl/tpl-data-fetch :: tpl-data-fetch"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:include="tpl/tpl-foot :: tpl-foot" class="tpl-foot"></div>
</body>
</html>
